﻿namespace LightINI
{
    partial class Ini
    {
        public delegate void PreEvent(object sender, PreEventArgs e);
        public delegate void PostEvent(object sender, PostEventArgs e);
        public class PostEventArgs : System.EventArgs
        {
            /// <summary>
            /// 更改的目标项
            /// </summary>
            public object Target { get; private set; }
            /// <summary>
            /// 更改的类型
            /// </summary>
            public ChangeType ChangeType { get; private set; }

            public PostEventArgs(ChangeType type, object target)
            {
                ChangeType = type;
                Target = target;
            }
        }

        public class PreEventArgs : PostEventArgs
        {
            /// <summary>
            /// 取消更改
            /// </summary>
            public bool Cancel { get; set; }

            public PreEventArgs(ChangeType type, object target) : base(type, target) { }
        }

        /// <summary>
        /// 文件
        /// </summary>
        public enum ChangeType
        {
            /// <summary>
            /// 添加配置项
            /// </summary>
            AddItem,
            /// <summary>
            /// 编辑配置项
            /// </summary>
            EditItem,
            /// <summary>
            /// 移除配置项
            /// </summary>
            RemoveItem,
            /// <summary>
            /// 添加配置配置段
            /// </summary>
            AddSection,
            /// <summary>
            /// 编辑配置配置段
            /// </summary>
            EditSection,
            /// <summary>
            /// 移除配置配置段
            /// </summary>
            RemoveSection,
        }
    }
}
